/**
 * 消息路由
 * 处理消息相关的API请求
 */
const express = require('express');
const router = express.Router();
const { protect } = require('../middleware/authMiddleware');
const { 
  sendMessage,
  getMessageById,
  deleteMessage,
  uploadFile
} = require('../controllers/messageController');
const upload = require('../middleware/uploadMiddleware');

// 路由配置
router.route('/')
  .post(protect, sendMessage); // 发送消息

// 上传文件消息（必须放在/:messageId路由前面）
router.route('/upload')
  .post(protect, upload.single('file'), uploadFile);

router.route('/:messageId')
  .get(protect, getMessageById) // 获取特定消息
  .delete(protect, deleteMessage); // 删除消息

module.exports = router; 